package Noyau;

import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

public abstract class ObjetMetier extends Observable
{
    private int ID;

    public int getID ()  
    {
        return this.ID;
    }
    
    public void setID(int value)
    {
    	this.ID = value;
    }
    
    public double getVisualSize()
    {
    	return 0;
    }
    
    public double getOpacity()
    {
    	return 1;
    }
    
    public Point2D getVisualOrigin()
    {
    	double dist = this.getVisualSize() / 2;
    	
    	double rotX = (Math.cos(this.getAngle()) * dist) + this.getCenter().getX();
		double rotY = (Math.sin(this.getAngle()) * dist) + this.getCenter().getY();
		
		return new Point2D.Double(rotX, rotY);
    }
	
	public List<ObjetMetier> getChildren()
	{
		return new ArrayList<ObjetMetier>();
	}
	
	public void click()
	{
		// Do nothing here, will be overrode when needed.
	}
	
	public void updateVisual()
	{
		for (ObjetMetier child : this.getChildren()) {
			child.updateVisual();
		}
		
		this.setChanged();
		this.notifyObservers();
	}
    
    public abstract Point2D getCenter();
    public abstract double getAngle();
    public abstract int getZBuffer();
}
